package weak_20241227_29.stream;

import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zdl
 * @date 2024/12/27
 */
public class Demo20 {
    public static void main(String[] args) {
        //20. 计算字符串中每个字符出现的次数
        String str = "abcabcabc";
        Map<Character, Long> collect = str.chars().mapToObj(s -> (char) s).collect(Collectors.groupingBy(s -> s, Collectors.counting()));
        System.out.println(collect);
    }
}
